import {
  Controller,
  Get,
  Post,
  Param,
  Body,
  Delete,
  UseFilters
} from '@nestjs/common'
import { UserService } from './user.service'
import { HttpExceptionFilter } from '../../exception/http-exception.filter'

@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  @Get('get/:id')
  getOne(@Param('id') id: number) {
    console.log(typeof id)
    return this.userService.findOne(id)
  }
  @Post('add')
  createOne(@Body() body) {
    return this.userService.createOneData(body)
  }
  @Delete('delete/:id')
  @UseFilters(new HttpExceptionFilter())
  removeOne(@Param('id') id) {
    return this.userService.deleteOneData(id)
  }
}
